export default {
  namespaced: true,
  state: {
    // 读取时候 先读取 localStorage  如果先读取 localStorage 里面有数据就用 localStorage 里面的数据
    historyKeywords: localStorage.getItem('historyKeywords') ? JSON.parse(localStorage.getItem('historyKeywords')) : []
  },
  mutations: {
    ['SET_HISTORY_KEYWORDS'] (state, payload) {
      state.historyKeywords = payload.historyKeywords
      // 把数据保存到 localStorage 里面  存储的时候先转成字符串，然后再存储
      localStorage.setItem('historyKeywords', JSON.stringify(payload.historyKeywords))
    },
    ['CLEAR_HISTORY_KEYWORDS'] (state) {
      state.historyKeywords = []
      localStorage.removeItem('historyKeywords')
    }
  },
  actions: {}

}
